import fetch from '@/utils/fetch'

// 获取机构树
export function getOrgTree() {
  return fetch({
    url: '/organizations',
    method: 'get'
  })
}

// 导入机构树
export function importOrgs(data) {
  return fetch({
    url: '/organizations',
    method: 'put',
    data
  })
}

// 更新机构
export function updateOrg({id, ...data}) {
  return fetch({
    url: `organizations/${id}`,
    method: 'put',
    data
  })
}

// 删除机构
export function deleteOrg(id) {
  return fetch({
    url: `/organizations/${id}`,
    method: 'delete',
  })
}

export function addOrg(parentId, data) {
  return fetch({
    url: `/organizations/${parentId}`,
    method: 'post',
    data
  })
}
